package tech.mobi.child;

import java.util.ArrayList;

import tech.mobi.child.base.BaseAct;
import tech.mobi.child.bean.MainClientAppBean;
import tech.mobi.child.utils.DBAppSource;
import tech.mobi.child.utils.UserInfo;
import tech.mobi.child.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 主
 * 
 * @author
 * @datetime 2013-9-12
 * 
 */
public class FirstClientAct extends BaseAct implements OnClickListener {

//	private TextView tvAccount;
	private ProgressBar progress;

	private LinearLayout linApp11;
	private LinearLayout linApp12;
	private LinearLayout linApp13;
	private LinearLayout linApp21;
	private LinearLayout linApp22;
	private LinearLayout linApp23;
	private LinearLayout linApp31;
	private LinearLayout linApp32;
	
	private ImageView ivHeader;
	private TextView tvName;
	private TextView tvAccount;
	private ImageView ivMessage;
	private ImageView ivSetting;
	
	
	@SuppressWarnings("unchecked")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.first_client_main);

		progress = (ProgressBar) this.findViewById(R.id.progress);
		tvAccount = (TextView) this.findViewById(R.id.tvAccount);

		tvName = (TextView) this.findViewById(R.id.tvName);
		ivHeader = (ImageView) this.findViewById(R.id.ivHeader);
		ivMessage = (ImageView) this.findViewById(R.id.ivMessage);
		ivMessage.setOnClickListener(this);
		ivSetting = (ImageView) this.findViewById(R.id.ivSetting);
		ivSetting.setOnClickListener(this);
		
		//chengzhang dang'an
		linApp11 = (LinearLayout) this.findViewById(R.id.linApp11);
		linApp11.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
				Intent intent = new Intent(FirstClientAct.this, CZDAClientMainAct.class);
				startActivity(intent);
			}
		});
		
		//jiaoliu zhongxin
		linApp12 = (LinearLayout) this.findViewById(R.id.linApp12);
		linApp12.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
				Intent intent = new Intent(FirstClientAct.this, JYGYClientListMainAct.class);
				startActivity(intent);
			}
		});
		
		//jinri suoxue
		linApp13 = (LinearLayout) this.findViewById(R.id.linApp13);
		linApp13.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Toast.makeText(FirstClientAct.this, "jinri suoxue", Toast.LENGTH_SHORT).show();
			}
		});
		
		//zaiyuan biaoxian
		linApp21 = (LinearLayout) this.findViewById(R.id.linApp21);
		linApp21.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Toast.makeText(FirstClientAct.this, "zaiyuan biaoxian", Toast.LENGTH_SHORT).show();
			}
		});
		
		//jiazhang zhutuo
		linApp22 = (LinearLayout) this.findViewById(R.id.linApp22);
		linApp22.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Toast.makeText(FirstClientAct.this, "jiazhang zhutuo", Toast.LENGTH_SHORT).show();
			}
		});
		

		//meiri shipu
		linApp23 = (LinearLayout) this.findViewById(R.id.linApp23);
		linApp23.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Toast.makeText(FirstClientAct.this, "meiri shipu", Toast.LENGTH_SHORT).show();
			}
		});
		
		//jiazhang jianyi
		linApp31 = (LinearLayout) this.findViewById(R.id.linApp31);
		linApp31.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Toast.makeText(FirstClientAct.this, "jiazhang jianyi", Toast.LENGTH_SHORT).show();
			}
		});
		
		//shezhi
		linApp32 = (LinearLayout) this.findViewById(R.id.linApp32);
		linApp32.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
				/*****注销  开始***********************/
				UserInfo.setUserId(FirstClientAct.this, "");
				UserInfo.setUserName(FirstClientAct.this, "");
				UserInfo.setPassword(FirstClientAct.this, "");
				UserInfo.setTrueName(FirstClientAct.this, "");
				UserInfo.setUserSex(FirstClientAct.this, "");
				UserInfo.setUserType(FirstClientAct.this, "");
				/*****注销  结束***********************/
				
				Toast.makeText(FirstClientAct.this, "shezhi", Toast.LENGTH_SHORT).show();
			}
		});
		
		tvAccount.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// progress.setVisibility(View.GONE);
				// Toast.makeText(FirstClientAct.this, "可以登录试试哦～",
				// Toast.LENGTH_LONG).show();

				Intent intent = new Intent(FirstClientAct.this,
						GoodClientListAct.class);
				FirstClientAct.this.startActivity(intent);

			}
		});
		String strUserName = UserInfo.getUserName(this);
		tvAccount
				.setText((strUserName == null || "".equals(strUserName)) ? "游客"
						: strUserName);
		// setClickEnable(false);

	}

	@Override
	public void init() {
	}

	@Override
	public void refresh(Object... param) {

	}

	@Override
	public void onClick(View v) {
		if(v.getId()==R.id.ivMessage) {
			Toast.makeText(this, "我的消息", Toast.LENGTH_LONG).show();
		} else if(v.getId()==R.id.ivSetting) {
			Toast.makeText(this, "设置", Toast.LENGTH_LONG).show();
		}

	}

	@SuppressWarnings("unused")
	private void setClickEnable(boolean bool) {
		if (bool) {
			this.progress.setVisibility(View.GONE);
		} else {
			this.progress.setVisibility(View.VISIBLE);
		}
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

}
